package moonshine
{
	import flash.events.EventDispatcher;

	public class TextEditorModel extends EventDispatcher
	{
		public var itemRenderersInUse:Array = [];
		public var itemRenderersFree:Array = [];
		
		public var lines:Array = [];
		
		public var selectedLineIndex:int = -1;
		public var caretIndex:int;
		
		public var selectionStartLineIndex:int = -1;
		public var selectionStartCharIndex:int = -1;
		
		public function get hasMultilineSelection():Boolean
		{
			return selectionStartLineIndex > -1 && selectedLineIndex != selectionStartLineIndex;
		}
		
		public function get hasSelection():Boolean
		{
			return selectionStartCharIndex != -1;
		}
		
		public function set selectedLine(v:String):void
		{
			lines[selectedLineIndex] = v;
		}
		public function get selectedLine():String
		{
			return lines[selectedLineIndex];
		}
	}
}